package com.mec.web.y2013.headfirstservlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

/**
 * Servlet implementation class Ch1Servlet
 * A simple Servlet to demonstrate the javaee Servlet function;
 * @since 2013-03-26
 * @author mec
 * @see Head first Servlets and JSP 2nd Edition;
 * 
 */
@WebServlet(urlPatterns = {"/2013/03_Mar/Ch1Time.action", "/2013/03_Mar/Ch1Servlet"})
public class Ch1Servlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Ch1Servlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		java.util.Date today = new java.util.Date();
		out.println("<html> " +
					"<body>" +
					"<h1 align = center> HF\'s Chapter1 Servlet</h1>"
					+ "<br>" + today + "</body>" + "</html>"
				);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	@SuppressWarnings("unused")
	private static final Logger logger = Logger.getLogger(Ch1Servlet.class);
}
